#!/usr/bin/env python
# coding:utf-8


from pandas_01_Object_Creation import *

print '============================================================================='
print df
"""
                   A         B         C         D
2017-01-01  0.906023 -1.627050  0.761667  0.221575
2017-01-02  1.037756 -0.634596 -0.426953 -0.516111
2017-01-03  0.143352  1.357909  0.557010 -0.068212
2017-01-04  0.708415 -1.446432 -0.279270  1.744724
2017-01-05 -0.352674  1.523332 -0.403732 -0.546899
2017-01-06 -1.078232  1.617094  0.883047  1.584371
"""
print '============================================================================='
print df.head(3)
print df.tail(3)
print '============================================================================='
print df.index
print df.columns
print df.values
"""
DatetimeIndex(['2017-01-01', '2017-01-02', '2017-01-03', '2017-01-04',
               '2017-01-05', '2017-01-06'],
              dtype='datetime64[ns]', freq='D')
"""
"""
Index([u'A', u'B', u'C', u'D'], dtype='object')
"""
"""
[[ 0.90602348 -1.6270504   0.76166733  0.22157515]
 [ 1.03775638 -0.63459634 -0.42695297 -0.51611111]
 [ 0.14335165  1.3579093   0.55701014 -0.06821172]
 [ 0.70841516 -1.44643212 -0.27926988  1.74472391]
 [-0.35267422  1.52333179 -0.40373198 -0.54689899]
 [-1.07823211  1.61709437  0.88304707  1.58437076]]
"""
print '============================================================================='
print df.describe()
"""
              A         B         C         D
count  6.000000  6.000000  6.000000  6.000000
mean   0.227440  0.131709  0.181962  0.403241
std    0.824234  1.537370  0.615596  1.019597
min   -1.078232 -1.627050 -0.426953 -0.546899
25%   -0.228668 -1.243473 -0.372616 -0.404136
50%    0.425883  0.361656  0.138870  0.076682
75%    0.856621  1.481976  0.710503  1.243672
max    1.037756  1.617094  0.883047  1.744724
"""
print '============================================================================='
# T = transpose 转置
print df.T
"""
   2017-01-01  2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06
A    0.906023    1.037756    0.143352    0.708415   -0.352674   -1.078232
B   -1.627050   -0.634596    1.357909   -1.446432    1.523332    1.617094
C    0.761667   -0.426953    0.557010   -0.279270   -0.403732    0.883047
D    0.221575   -0.516111   -0.068212    1.744724   -0.546899    1.584371
"""
print '============================================================================='
print df.sort_index(axis=1, ascending=False)
"""
                   D         C         B         A
2017-01-01  0.221575  0.761667 -1.627050  0.906023
2017-01-02 -0.516111 -0.426953 -0.634596  1.037756
2017-01-03 -0.068212  0.557010  1.357909  0.143352
2017-01-04  1.744724 -0.279270 -1.446432  0.708415
2017-01-05 -0.546899 -0.403732  1.523332 -0.352674
2017-01-06  1.584371  0.883047  1.617094 -1.078232
"""
print '============================================================================='
print df.sort_values(by='A')
"""
                   A         B         C         D
2017-01-06 -1.078232  1.617094  0.883047  1.584371
2017-01-05 -0.352674  1.523332 -0.403732 -0.546899
2017-01-03  0.143352  1.357909  0.557010 -0.068212
2017-01-04  0.708415 -1.446432 -0.279270  1.744724
2017-01-01  0.906023 -1.627050  0.761667  0.221575
2017-01-02  1.037756 -0.634596 -0.426953 -0.516111
"""
print '============================================================================='
